import { store } from "../../../store/index";

Component({
  properties: {
    type: String,
    data: {
      type: Object,
      value: {},
    },
  },
  methods: {
    help() {
      // console.log("help", store.userInfo.applyStatus);
      if (
        store.userInfo?.applyStatus === "未申请" ||
        store.userInfo?.applyStatus === "驳回"
      ) {
        wx.showModal({
          title: "提示",
          content: "您还没有成为接单员，是否前往申请。",
          confirmColor: "#409eff",
          confirmText: "立即前往",
          cancelText: "取消",
          success: function (res) {
            if (res.confirm) {
              // 用户点击了确定
              console.log("用户点击确定");
              wx.navigateTo({
                url: `/pages/me_content/aplay`,
              });
            }
          },
        });
      } else if (store.userInfo?.applyStatus === "申请中") {
        wx.showToast({
          title: "您正在申请接单员，请耐心等待审核",
          icon: "none",
        });
        return;
      } else {
        wx.navigateTo({
          url: `/pages/order/detail/index?id=${this.data.data.id}&type=${'10002'}`,
        });
      }
    },
    
    toDetail(e) {

      console.log(this.data.type, 'this.data.data');
      if(this.data.type === '10002' && this.data.data.status === '待支付') {
        wx.navigateTo({
          url: `/pages/confirmOrder/index?id=${this.data.data.id}`,
        }); 
        return;
      }
      if(this.data.type === '10004' && this.data.data.status === '进行中') {
        wx.navigateTo({
          url: `/pages/order/detail/index?id=${this.data.data.id}&type=10004`,
        });
        return;
      }
      wx.navigateTo({
        url: `/pages/order/detail/index?id=${this.data.data.id}&type=${this.data.type}`,
      });
    },
  },
});
